<div class="flex flex-col h-100">
  <h2 class="crayons-subtitle-1"><%= t("views.admin.users.emails.previous", num: @user.email_messages.count) %></h2>
  <% if @user.email_messages.empty? %>
    <div class="align-center flex flex-col justify-center my-auto py-7">
      <h3 class="crayons-subtitle-2 mb-2"><%= t("views.admin.users.emails.empty1", user: @user.name) %></h3>
      <p class="color-secondary"><%= t("views.admin.users.emails.empty2", email: @user.email) %></p>
    </div>
  <% else %>
    <div class="pt-3">
      <% @user.email_messages.order(sent_at: :desc).limit(50).each do |email| %>
        <article class="c-list-item flex justify-between gap-4">
          <h3 class="flex-1 fw-medium lh-tight fs-base">
            <a href="<%= admin_user_email_message_path(@user, email) %>" class="c-link" rel="noopener noreferer" target="_blank">
              <%= email.subject %>
            </a>
          </h3>
          <time datetime="<%= email.sent_at&.strftime("%Y-%m-%dT%H:%M:%S%z") %>" class="color-secondary fs-s shrink-0" title="<%= l(email.sent_at, format: :admin_user) if email.sent_at %>">
            <%= l(email.sent_at, format: :short_with_yy) if email.sent_at %>
          </time>
        </article>
      <% end %>
    </div>
  <% end %>
</div>
